<?php 
include 'conf/db-config.php';
class MyClass {
      
	function FetchUserRecords($id)
	{
		$sql="SELECT u.full_name as fullname,l.user_name as username,l.password as userpassword,l.email as useremail,u.dob as userdob,u.gender as usergender,u.country as usercountry,u.contact_no as usercontact, l.is_admin FROM login_detail l,user_detail u WHERE l.user_name=u.user_name AND u.id=".$id;
		
		$result=mysql_query($sql);
		$userdetails = array();
		while ($row = mysql_fetch_array($result))
		{
			$userdetails["fullname"] = $row["fullname"];
			$userdetails["username"] = $row["username"];
			$userdetails["userpassword"] = $row["userpassword"];
			$userdetails["useremail"] = $row["useremail"];
			$userdetails["userdob"] = $row["userdob"];
			$userdetails["usergender"] = $row["usergender"];
			$userdetails["usercountry"] = $row["usercountry"];
			$userdetails["usercontact"] = $row["usercontact"];
			$userdetails["is_admin"] = $row["is_admin"];
		}
		return $userdetails;
	}
	function UpdateUserRecords($username,$fullname,$dob,$email)
	{
		$sql="UPDATE user_detail SET fullname = '".$fullname."' ,dob =  '".$dob."' WHERE user_name='".$username."'";
		$result=mysql_query($sql);
		
		$sql1="UPDATE login_detail SET email = '".$email."' WHERE user_name='".$username."'";
		$result1=mysql_query($sql1);
		
		print $sql."---".$sql1;
		
	}
	
	function GetCompanyNames()
	{
		$sql="SELECT company_name,value,id FROM tbl_employer_details order by company_name";

		$result=mysql_query($sql);
		$companydetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$companydetails[$cnt]["company_name"] = $row["company_name"];
			$companydetails[$cnt]["value"] = $row["value"];
			$companydetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $companydetails;		
	}
	
	function GetDesignationRecords()
	{
		$sql="SELECT designation_title,value,id FROM tbl_designation_details order by designation_title";

		$result=mysql_query($sql);
		$designationdetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$designationdetails[$cnt]["designation_title"] = $row["designation_title"];
			$designationdetails[$cnt]["value"] = $row["value"];
			$designationdetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $designationdetails;		
	}
	
	function GetEducationDetails()
	{
		$sql="SELECT education_title,value,id FROM tbl_higher_education order by value";

		$result=mysql_query($sql);
		$educationdetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$educationdetails[$cnt]["education_title"] = $row["education_title"];
			$educationdetails[$cnt]["value"] = $row["value"];
			$educationdetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $educationdetails;		
	}
	
	function GetUniversityDetails()
	{
		$sql="SELECT university_name,country,value,id FROM tbl_university_details order by university_name";

		$result=mysql_query($sql);
		$universitydetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$universitydetails[$cnt]["university_name"] = $row["university_name"];
			$universitydetails[$cnt]["country"] = $row["country"];
			$universitydetails[$cnt]["value"] = $row["value"];
			$universitydetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $universitydetails;		
	}
	/**************** For Work Experience ***********************************/
	function InsertWorkDetails($username,$company,$department,$designation,$experience)
	{
		$sql='INSERT INTO employment (user_name,company,department,designation,experience) VALUES ("'.$username.'","'.$company.'","'.$department.'","'.$designation.'","'.$experience.'")';
		$result=mysql_query($sql);	
	}
	
	function DeleteWorkDetails($username)
	{
		$sql='DELETE FROM employment WHERE user_name='.$username;
		$result=mysql_query($sql);	
	}
	
	function ShowIndividualUserWorkHistoryDetails($username)
	{
		$sql="SELECT company,department,designation,experience FROM employment WHERE user_name=".$username;
		$result=mysql_query($sql);
		$userworkhistorydetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$userworkhistorydetails[$cnt]["company"] = $row["company"];
			$userworkhistorydetails[$cnt]["department"] = $row["department"];
			$userworkhistorydetails[$cnt]["designation"] = $row["designation"];
			$userworkhistorydetails[$cnt]["experience"] = $row["experience"];
			$cnt++;
		}
		return $userworkhistorydetails;		
	}
	/**************** For Work Experience ***********************************/
	
	
	/**************** For Education ***********************************/
	function InsertEducationDetails($username,$university,$year,$course,$grade,$heducation)
	{
		$sql='INSERT INTO education (user_name,university,year,course,grade,highesteducation) VALUES ("'.$username.'","'.$university.'","'.$year.'","'.$course.'","'.$grade.'","'.$heducation.'")';
		$result=mysql_query($sql);	
	}
	
	function DeleteEducationDetails($username)
	{
		$sql='DELETE FROM education WHERE user_name='.$username;
		$result=mysql_query($sql);	
	}
	
	function ShowIndividualUserEducationDetails($username)
	{
		$sql="SELECT university,year,course,grade,highesteducation FROM education WHERE user_name=".$username;
		$result=mysql_query($sql);
		$usereducationdetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$usereducationdetails[$cnt]["university"] = $row["university"];
			$usereducationdetails[$cnt]["year"] = $row["year"];
			$usereducationdetails[$cnt]["course"] = $row["course"];
			$usereducationdetails[$cnt]["grade"] = $row["grade"];
			$usereducationdetails[$cnt]["highesteducation"] = $row["highesteducation"];
			$cnt++;
		}
		return $usereducationdetails;		
	}
	/**************** For Education ***********************************/
	
	
	/**************** For Additional Education ***********************************/
	function InsertAddEducationDetails($username,$addeducation)
	{
		$sql='INSERT INTO addeducation (user_name,addeducationdetails) VALUES ("'.$username.'","'.$addeducation.'")';
		$result=mysql_query($sql);	
		
	}
	
	function DeleteAddEducationDetails($username)
	{
		$sql='DELETE FROM addeducation WHERE user_name='.$username;
		$result=mysql_query($sql);	
	}
	
	function ShowIndividualUserAddEducationDetails($username)
	{
		$sql="SELECT addeducationdetails FROM addeducation WHERE user_name=".$username;
		$result=mysql_query($sql);
		$useraddeducationdetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$useraddeducationdetails[$cnt]["addeducationdetails"] = $row["addeducationdetails"];			
			$cnt++;
		}
		return $useraddeducationdetails;		
	}
	/**************** For Additional Education ***********************************/
	
	/**************** For Extra Curricular ***********************************/
	function InsertExtraCurricularDetails($username,$organisation,$designation,$key_project,$hours_week)
	{
		$sql='INSERT INTO extra_curricular (user_name,organisation,designation,key_project,hours_week) VALUES ("'.$username.'","'.$organisation.'","'.$designation.'","'.$key_project.'","'.$hours_week.'")';
		$result=mysql_query($sql);	
	}
	
	function DeleteExtraCurricularDetails($username)
	{
		$sql='DELETE FROM extra_curricular WHERE user_name='.$username;
		$result=mysql_query($sql);	
	}
	
	function ShowIndividualUserExtraCurricularDetails($username)
	{
		$sql="SELECT organisation,designation,key_project,hours_week FROM extra_curricular WHERE user_name=".$username;
		$result=mysql_query($sql);
		$userextracurriculardetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$userextracurriculardetails[$cnt]["organisation"] = $row["organisation"];
			$userextracurriculardetails[$cnt]["designation"] = $row["designation"];
			$userextracurriculardetails[$cnt]["key_project"] = $row["key_project"];
			$userextracurriculardetails[$cnt]["hours_week"] = $row["hours_week"];
			$cnt++;
		}
		return $userextracurriculardetails;		
	}
	/**************** For Extra Curricular ***********************************/


	/**************** For GMAT***********************************/
	function InsertGMATDetails($username,$valid_score,$expected_score)
	{
		$sql='INSERT INTO gmat (user_name,score,expected_score) VALUES ("'.$username.'","'.$valid_score.'","'.$expected_score.'")';
		$result=mysql_query($sql);	
	}
	
	function DeleteGMATDetails($username)
	{
		$sql='DELETE FROM gmat WHERE user_name='.$username;
		$result=mysql_query($sql);	
	}
	
	function ShowIndividualUserGMATDetails($username)
	{
		$sql = "SELECT score,expected_score FROM gmat WHERE user_name=".$username;
		$result = mysql_query($sql);
		$usergmatdetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$usergmatdetails["score"] = $row["score"];
			$usergmatdetails["expected_score"] = $row["expected_score"];
			$cnt++;
		}
		return $usergmatdetails;		
	}
	/**************** For Extra Curricular ***********************************/
	
	function GetBSchoolDetails()
	{
		$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools order by id";

		$result=mysql_query($sql);
		$BSchooldetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$BSchooldetails[$cnt]["school_name"] = $row["school_name"];
			$BSchooldetails[$cnt]["avg_gmat_score"] = $row["avg_gmat_score"];
			$BSchooldetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $BSchooldetails;		
	}
	
	function GetBSchoolDetailsForChoice($choice)
	{
		if($choice == 1)
		{
			$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools order by id ASC LIMIT 20";
		}
		else if($choice == 2)
		{
			$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools WHERE id between 21 AND 40 order by id asc";
		}
		else if($choice == 3)
		{
			$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools WHERE id between 41 AND 60 order by id asc";
		}
		else if($choice == 4)
		{
			$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools WHERE id between 61 AND 80 order by id asc";
		}
		$result=mysql_query($sql);
		$BSchooldetails = array();
		$cnt = 0;
		while ($row = mysql_fetch_array($result))
		{
			$BSchooldetails[$cnt]["school_name"] = $row["school_name"];
			$BSchooldetails[$cnt]["avg_gmat_score"] = $row["avg_gmat_score"];
			$BSchooldetails[$cnt]["id"] = $row["id"];
			$cnt++;
		}
		return $BSchooldetails;		
	}
	
	function GetBschoolNames($id)
	{
		$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools WHERE id=".$id;
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolNames = $row["school_name"];			

		}
		return $BSchoolNames;		
	}
	
	function GetBschoolAvarageGmatScore($id)
	{
		$sql="SELECT school_name,avg_gmat_score,id FROM tbl_business_schools WHERE id=".$id;
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolNames = $row["avg_gmat_score"];			

		}
		return $BSchoolNames;		
	}
	
	function GetBschoolWorkExperience($id)
	{
		$sql="SELECT school_name,avg_gmat_score,id,work_experience FROM tbl_business_schools WHERE id=".$id;
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolWorkExperience = $row["work_experience"];			

		}
		return $BSchoolWorkExperience;		
	}
	
	function GetBschoolAvgSalary($id)
	{
		$sql="SELECT school_name,avg_gmat_score,id,avg_salary FROM tbl_business_schools WHERE id=".$id;
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolAvgSalary = $row["avg_salary"];			

		}
		return $BSchoolAvgSalary;		
	}

	function GetBschoolProgramLength($id)
	{
		$sql="SELECT school_name,avg_gmat_score,id,program_length FROM tbl_business_schools WHERE id=".$id;
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolProgramLength = $row["program_length"];			

		}
		return $BSchoolProgramLength;		
	}
	
	function getConsultingPackage($id)
	{
		$BSchoolProgramLength=array();
		$sql="SELECT package FROM tbl_user_admission_package WHERE user_id=".$id;
		$result=mysql_query($sql);
		$cnt=0;
		while ($row = mysql_fetch_array($result))
		{
			$BSchoolProgramLength[$cnt] = $row["package"];			
			$cnt++;
		}
		return $BSchoolProgramLength;
	
	}
	
	function remove_element($arr, $val)
	{
			foreach ($arr as $key => $value)
			{
				if ($arr[$key] == $val)
				{
					unset($arr[$key]);
					break;
				}
			}
		return $arr = array_values($arr);
	}
	
	
	function getBoughtResources($id)
	{
		$BSchoolProgramLength=array();
		$sql="SELECT updates FROM tbl_recent_update WHERE user_id=".$id;
		$result=mysql_query($sql);
		$cnt=0;
		$arrTest = array();
		while ($row = mysql_fetch_array($result))
		{
			$string = $row["updates"];
			$arrTest = explode("You have successfully bought a ",$string );
			$BSchoolProgramLength[$cnt] = $arrTest[1];			
			$cnt++;
		}
		return $BSchoolProgramLength;
	
	}
	
}

?>